home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 443_01 / doc / info / cncl.info-3 < prev    next >
Encoding:
GNU Info File  |  1996-01-04  |  49.3 KB  |  1,958 lines

  1. This is Info file cncl.info, produced by Makeinfo-1.63 from the input
  2. file cncl.texi.
  3.  
  4.    This file documents the use of CNCL, the Communication Networks Class
  5. Library.
  6.  
  7.    Copyright (C) 1993-1996, Communication Networks.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided that the
  15. entire resulting derived work is distributed under the terms of a
  16. permission notice identical to this one.
  17.  
  18.    Permission is granted to copy and distribute translations of this
  19. manual into other languages, under the above conditions for modified
  20. versions.
  21.  
  22. 
  23. File: cncl.info,  Node: CNSLList,  Next: CNSLObject,  Prev: CNAVLNode,  Up: Container
  24.  
  25. CNSLList -- Single Linked List of Objects
  26. =========================================
  27.  
  28. SYNOPSIS
  29. --------
  30.  
  31.    `#include <CNCL/SLList.h>'
  32.  
  33. TYPE
  34. ----
  35.  
  36.    `CN_SLLIST'
  37.  
  38. * Menu:
  39.  
  40. BASE CLASSES
  41. ------------
  42. * CNObject::        Root of the CNCL Hierarchy
  43.  
  44. DERIVED CLASSES
  45. ---------------
  46. * CNDLList::        Doubly Linked List of Objects
  47.  
  48. RELATED CLASSES
  49. ---------------
  50. * CNSLObject::        Node of Single Linked List
  51. * CNSLIterator::    Iterator of Single Linked List
  52.  
  53. DESCRIPTION
  54. -----------
  55.  
  56.    `CNSLList' is a single linked list that can contain any CNCL
  57. compatible object.
  58.  
  59.    Constructors:
  60.  
  61. `CNSLList();'
  62. `CNSLList(CNParam *param);'
  63.      Initializes the list to empty state.
  64.  
  65.      Please note, that there is NO copy constructor supplied. Any
  66.      attempt to copy a CNSLList will yield a fatal error.
  67.  
  68.    Destructors:
  69.  
  70. `~CNSLList();'
  71.      Deletes the linked list and all `CNSLObject' nodes. It does NOT
  72.      delete the objects referenced by the nodes.
  73.  
  74.    In addition to the member functions required by CNCL, `CNSLList'
  75. provides:
  76.  
  77. `CNSLObject *first() const;'
  78.      Returns the first node in the list or `NIL' if the list is empty.
  79.  
  80. `virtual CNSLObject *last() const;'
  81.      Returns the last node in the list or `NIL' if the list is empty.
  82.  
  83. `CNSLObject *next(CNSLObject *link) const;'
  84.      Returns the next node in the list, where `link' points to the
  85.      current node. This may be `NIL' if the next node doesn't exist.
  86.  
  87. `virtual CNSLObject *prev(CNSLObject *link) const;'
  88.      Returns the previous node in the list, where `link' points to the
  89.      current node. This may be `NIL' if the previous node doesn't exist.
  90.  
  91. `bool empty() const;'
  92.      Checks if `DLList' is empty.
  93.  
  94. `unsigned long length() const;'
  95.      Returns the length (number of nodes) of this `DLList'.
  96.  
  97. `virtual CNSLObject *append(CNObject *obj);'
  98. `virtual CNSLObject *append(CNObject &obj);'
  99.      Adds a new node to the end of the list, referencing the object
  100.      `obj'. It returns the node allocated for the object.
  101.  
  102. `virtual CNSLObject *append(CNSLObject *obj);'
  103.      Adds an already allocated node to the list. It returns the pointer
  104.      `obj'.
  105.  
  106. `virtual CNSLObject *prepend(CNObject *obj);'
  107. `virtual CNSLObject *prepend(CNObject &obj);'
  108.      Adds a new node to the start of the list, referencing the object
  109.      `obj'. It returns the node allocated for the object.
  110.  
  111. `virtual CNSLObject *prepend(CNSLObject *obj);'
  112.      Adds an already allocated node to the list. It returns the pointer
  113.      `obj'.
  114.  
  115. `virtual CNSLObject *delete_object(CNSLObject *pos);'
  116.      Deletes the node `pos' from the list. It returns the next node.
  117.      This function deletes the node (`CNSLObject') from the list, but
  118.      it does NOT delete the object referenced by the node.
  119.  
  120. `virtual CNSLObject *remove_object(CNSLObject *pos);'
  121.      Removes the node `pos' from the list. It returns the next node.
  122.      This function does NOT delete the linked list node (`CNSLObject')
  123.      and it does NOT delete the object referenced by the node, either.
  124.  
  125. `void delete_all();'
  126.      Deletes all nodes from the linked list and initializes the list to
  127.      empty. The objects referenced by the nodes are NOT deleted.
  128.  
  129. `void delete_all_w_obj();'
  130.      Deletes all nodes from the linked list, initializes the list to
  131.      empty, AND deletes the referenced objects.
  132.  
  133. `virtual CNSLObject *insert_before(CNSLObject *pos, CNObject *obj);'
  134. `virtual CNSLObject *insert_before(CNSLObject *pos, CNObject &obj);'
  135.      Creates a new node for `obj' and inserts it into the list before
  136.      node `pos'. It returns the new node.
  137.  
  138. `virtual CNSLObject *insert_before(CNSLObject *pos, CNSLObject *obj);'
  139.      Inserts an already allocated node into the list before node `pos'.
  140.      It returns `obj'.
  141.  
  142. `virtual CNSLObject *insert_after(CNSLObject *pos, CNObject *obj);'
  143. `virtual CNSLObject *insert_after(CNSLObject *pos, CNObject &obj);'
  144.      Creates a new node for `obj' and inserts it into the list after
  145.      node `pos'. It returns the new node.
  146.  
  147. `virtual CNSLObject *insert_after(CNSLObject *pos, CNSLObject *obj);'
  148.      Inserts an already allocated node into the list after node `pos'.
  149.      It returns `obj'.
  150.  
  151. 
  152. File: cncl.info,  Node: CNSLObject,  Next: CNSLIterator,  Prev: CNSLList,  Up: Container
  153.  
  154. CNSLObject -- Node of Single Linked List
  155. ========================================
  156.  
  157. SYNOPSIS
  158. --------
  159.  
  160.    `#include <CNCL/SLObject.h>'
  161.  
  162. TYPE
  163. ----
  164.  
  165.    `CN_SLOBJECT'
  166.  
  167. * Menu:
  168.  
  169. BASE CLASSES
  170. ------------
  171. * CNObject::        Root of the CNCL hierarchy
  172.  
  173. DERIVED CLASSES
  174. ---------------
  175. * CNDLObject::        Node of Doubly Linked List
  176.  
  177. RELATED CLASSES
  178. ---------------
  179. * CNSLList::        Single Linked List of Objects
  180. * CNSLIterator::    Iterator of Single Linked List
  181.  
  182. DESCRIPTION
  183. -----------
  184.  
  185.    `CNSLObject' is a node in the `CNSLList' single linked list. It
  186. contains a pointer to the next and a pointer to the referenced object.
  187.  
  188.    Constructors:
  189.  
  190. `CNSLObject();'
  191. `CNSLObject(CNParam *param);'
  192. `CNSLObject(CNObject *obj);'
  193.      Initializes `CNSLObject' and optionally sets a referenced object.
  194.  
  195.    `CNSLObject's have a private destructor and can therefore only be
  196. allocated on the heap. Furthermore `CNSLObject's cannot be copied, no
  197. copy constructor is supplied; an attempt to do so results in a runtime
  198. error.
  199.  
  200.    In addition to the member functions required by CNCL, `CNSLObject'
  201. provides:
  202.  
  203. `CNSLObject *set_next(CNSLObject *p);'
  204. `CNSLObject *next(CNSLObject *p);'
  205. `CNSLObject *get_next();'
  206. `CNSLObject *next();'
  207.      Sets/gets the pointer to the next node. It returns the current
  208.      pointer.
  209.  
  210. `CNObject *object(CNObject *obj);'
  211. `CNObject *object();'
  212. `CNObject *set_object(CNObject *obj);'
  213. `CNObject *get_object();'
  214.      Gets/sets the pointer to the referenced object. It returns the
  215.      current value.
  216.  
  217. `void delete_object();'
  218.      Deletes the referenced object.
  219.  
  220. 
  221. File: cncl.info,  Node: CNSLIterator,  Next: CNDLList,  Prev: CNSLObject,  Up: Container
  222.  
  223. CNSLIterator -- Iterator of Single Linked List
  224. ==============================================
  225.  
  226. SYNOPSIS
  227. --------
  228.  
  229.    `#include <CNCL/SLIterator.h>'
  230.  
  231. TYPE
  232. ----
  233.  
  234.    `CN_SLITERATOR'
  235.  
  236. * Menu:
  237.  
  238. BASE CLASSES
  239. ------------
  240. * CNObject::        Root of the CNCL Hierarchy
  241.  
  242. DERIVED CLASSES
  243. ---------------
  244. * CNDLIterator::    Iterator of Doubly Linked List
  245.  
  246. RELATED CLASSES
  247. ---------------
  248. * CNSLList::        Single Linked List of Objects
  249. * CNSLObject::        Node of Single Linked List
  250.  
  251. DESCRIPTION
  252. -----------
  253.  
  254.    `CNSLIterator' is an iterator to traverse a `CNSLList' single linked
  255. list.
  256.  
  257.    Constructors:
  258.  
  259. `CNSLIterator();'
  260. `CNSLIterator(CNParam *param);'
  261.      Initializes `CNSLIterator'.
  262.  
  263. `CNSLIterator(const CNSLList *new_list);'
  264. `CNSLIterator(const CNSLList &new_list);'
  265.      Initializes `CNSLIterator' with linked list `list'. The iterator
  266.      is reset to the first element in the list.
  267.  
  268.    In addition to the member functions required by CNCL, `CNSLIterator'
  269. provides:
  270.  
  271. `void reset(const CNSLList *new_list);'
  272. `void reset(const CNSLList &new_list);'
  273. `void reset();'
  274.      Resets the iterator to a new list `new_list' and/or sets the
  275.      iterator to the first element in the list.
  276.  
  277. `CNObject *object()'
  278. `CNObject *get_object()'
  279.      Gets the referenced object from the current iterator position. It
  280.      returns the object or `NIL', if none is available.
  281.  
  282. `CNSLObject *position()'
  283. `CNSLObject *get_position()'
  284.      Gets the current iterator position (node in the list). It returns a
  285.      pointer to the node or `NIL', if none is available.
  286.  
  287. `CNObject *first_object();'
  288. `CNObject *first();'
  289.      Sets the iterator to the first element in the list. It returns the
  290.      referenced object or `NIL', if none is available.
  291.  
  292. `CNObject *last_object();'
  293. `CNObject *last();'
  294.      Sets the iterator to the last element in the list. It returns the
  295.      referenced object or `NIL', if none is available.
  296.  
  297. `CNObject *next_object();'
  298. `CNObject *next();'
  299. `CNObject *operator ++();'
  300. `CNObject *operator ++(int);'
  301.      Moves the iterator to the next element in the list. It returns the
  302.      current referenced object (the one BEFORE moving the iterator) or
  303.      `NIL', if none is available.
  304.  
  305.    An example which shows the use of a `Iterators' object to traverse a
  306. double linked list can be found at the end of the class `CNDIterator'.
  307.  
  308. 
  309. File: cncl.info,  Node: CNDLList,  Next: CNDLObject,  Prev: CNSLIterator,  Up: Container
  310.  
  311. CNDLList -- Doubly Linked List of Objects
  312. =========================================
  313.  
  314. SYNOPSIS
  315. --------
  316.  
  317.    `#include <CNCL/DLList.h>'
  318.  
  319. TYPE
  320. ----
  321.  
  322.    `CN_DLLIST'
  323.  
  324. * Menu:
  325.  
  326. BASE CLASSES
  327. ------------
  328. * CNSLList::             Single Linked List
  329.  
  330. DERIVED CLASSES
  331. ---------------
  332.  
  333. RELATED CLASSES
  334. ---------------
  335. * CNDLObject::        Node of Doubly Linked List
  336. * CNDLIterator::    Iterator of Doubly Linked List
  337.  
  338. DESCRIPTION
  339. -----------
  340.  
  341.    `CNDLList' is a doubly linked list that can contain any CNCL
  342. compatible object.
  343.  
  344.    Constructors:
  345.  
  346. `CNDLList();'
  347. `CNDLList(CNParam *param);'
  348.      Initializes the list to empty state.
  349.  
  350.      Please note, that there is NO copy constructor supplied. Any
  351.      attempt to copy a CNDLList will yield a fatal error.
  352.  
  353.    Destructors:
  354.  
  355. `~CNDLList();'
  356.      Deletes the linked list and all `CNDLObject' nodes. It does NOT
  357.      delete the objects referenced by the nodes.
  358.  
  359.    In addition to the member functions required by CNCL and to the
  360. functions supplied by `CNSLList', `CNDLList' provides or defines more
  361. efficiently:
  362.  
  363. `CNDLObject *last() const;'
  364.      Returns the last node in the list or `NIL' if the list is empty.
  365.  
  366. `CNDLObject *prev(CNDLObject *link) const;'
  367.      Returns the previous node in the list, where `link' points to the
  368.      current node. This may be `NIL' if the previous node doesn't exist.
  369.  
  370. `CNDLObject *append(CNObject *obj);'
  371. `CNDLObject *append(CNObject &obj);'
  372.      Adds a new node to the end of the list, referencing the object
  373.      `obj'. It returns the node allocated for the object.
  374.  
  375. `CNDLObject *append(CNDLObject *obj);'
  376.      Adds an already allocated node to the list. It returns the pointer
  377.      `obj'.
  378.  
  379. `CNDLObject *insert_before(CNDLObject *pos, CNObject *obj);'
  380. `CNDLObject *insert_before(CNDLObject *pos, CNObject &obj);'
  381.      Creates a new node for `obj' and inserts it into the list before
  382.      node `pos'. It returns the new node.
  383.  
  384. `CNDLObject *insert_before(CNDLObject *pos, CNDLObject *obj);'
  385.      Inserts an already allocated node into the list before node `pos'.
  386.      It returns `obj'.
  387.  
  388. `bool ok();'
  389.      Checks the list for consistency. It returns `TRUE', if the list is
  390.      o.k.
  391.  
  392. 
  393. File: cncl.info,  Node: CNDLObject,  Next: CNDLIterator,  Prev: CNDLList,  Up: Container
  394.  
  395. CNDLObject -- Node of Doubly Linked List
  396. ========================================
  397.  
  398. SYNOPSIS
  399. --------
  400.  
  401.    `#include <CNCL/DLObject.h>'
  402.  
  403. TYPE
  404. ----
  405.  
  406.    `CN_DLOBJECT'
  407.  
  408. * Menu:
  409.  
  410. BASE CLASSES
  411. ------------
  412. * CNSLObject::        Node of Single Linked List
  413.  
  414.  
  415. DERIVED CLASSES
  416. ---------------
  417.  
  418. RELATED CLASSES
  419. ---------------
  420. * CNDLList::        Doubly Linked List of Objects
  421. * CNDLIterator::    Iterator of Doubly Linked List
  422.  
  423. DESCRIPTION
  424. -----------
  425.  
  426.    `CNDLObject' is a node in the `CNDLList' doubly linked list. In
  427. addition to the base class it contains a pointer to the previous node.
  428.  
  429.    Constructors:
  430.  
  431. `CNDLObject();'
  432. `CNDLObject(CNParam *param);'
  433. `CNDLObject(CNObject *obj);'
  434.      Initializes `CNDLObject' and optionally sets a referenced object.
  435.  
  436.    `CNDLObject's have a private destructor and can therefore only be
  437. allocated on the heap. Furthermore `CNDLObject's cannot be copied, no
  438. copy constructor is supplied; an attempt do so results in a runtime
  439. error.
  440.  
  441.    In addition to the member functions required by CNCL and to the
  442. functions declared at `CNSLObject', `CNDLObject' provides:
  443.  
  444. `CNDLObject *prev(CNDLObject *p);'
  445. `CNDLObject *prev();'
  446. `CNDLObject *set_prev(CNDLObject *p);'
  447. `CNDLObject *get_prev();'
  448.      Gets/sets the pointer to the previous node. It returns the current
  449.      pointer.
  450.  
  451. 
  452. File: cncl.info,  Node: CNDLIterator,  Next: CNQueue,  Prev: CNDLObject,  Up: Container
  453.  
  454. CNDLIterator -- Iterator of Doubly Linked List
  455. ==============================================
  456.  
  457. SYNOPSIS
  458. --------
  459.  
  460.    `#include <CNCL/DLIterator.h>'
  461.  
  462. TYPE
  463. ----
  464.  
  465.    `CN_DLITERATOR'
  466.  
  467. * Menu:
  468.  
  469. BASE CLASSES
  470. ------------
  471. * CNSLIterator::    Iterator of Single Linked List
  472.  
  473.  
  474. DERIVED CLASSES
  475. ---------------
  476.  
  477. RELATED CLASSES
  478. ---------------
  479. * CNDLList::        Doubly Linked List of Objects
  480. * CNDLObject::        Node of Doubly Linked List
  481.  
  482. DESCRIPTION
  483. -----------
  484.  
  485.    `CNDLIterator' is an iterator to traverse a `CNDLList' doubly linked
  486. list.
  487.  
  488.    Constructors:
  489.  
  490. `CNDLIterator();'
  491. `CNDLIterator(CNParam *param);'
  492.      Initializes `CNDLIterator'.
  493.  
  494. `CNDLIterator(const CNDLList *new_list);'
  495. `CNDLIterator(const CNDLList &new_list);'
  496.      Initializes `CNDLIterator' with linked list `list'. The iterator
  497.      is reset to the first element in the list.
  498.  
  499.    In addition to the member functions required by CNCL, `CNDLIterator'
  500. provides or defines more efficiently:
  501.  
  502. `void reset(const CNDLList *new_list);'
  503. `void reset(const CNDLList &new_list);'
  504. `void reset();'
  505.      Resets the iterator to a new list `new_list' and/or sets the
  506.      iterator to the first element in the list.
  507.  
  508. `CNDLObject *position()'
  509. `CNDLObject *get_position()'
  510.      Gets the current iterator position (node in the list). It returns a
  511.      pointer to the node or `NIL', if none is available.
  512.  
  513. `CNObject *last_object();'
  514. `CNObject *last();'
  515.      Sets the iterator to the last element in the list. It returns the
  516.      referenced object or `NIL', if none is available.
  517.  
  518. `CNObject *prev_object();'
  519. `CNObject *prev();'
  520. `CNObject *operator --();'
  521. `CNObject *operator --(int);'
  522.      Moves the iterator to the previous element in the list. It returns
  523.      the current referenced object (the one BEFORE moving the iterator)
  524.      or `NIL', if none is available.
  525.  
  526.    The following examples show how to use a `CNDLIterator' object to
  527. traverse a linked list:
  528.  
  529. Forward:
  530.  
  531.      CNDLList list;
  532.      
  533.      ...
  534.      
  535.      CNDLIterator trav(list);
  536.      CNObject *obj;
  537.      
  538.      while(obj = trav++)
  539.      {
  540.          // Do something with obj ...
  541.      }
  542.  
  543. Alternate forward:
  544.  
  545.      for(trav.reset(list); obj=trav.object(); trav.next())
  546.      {
  547.          // ...
  548.      }
  549.  
  550. Backward:
  551.  
  552.      for(trav.last(); obj=trav.object(); trav--)
  553.      {
  554.          // ...
  555.      }
  556.  
  557. 
  558. File: cncl.info,  Node: CNQueue,  Next: CNQueueFIFO,  Prev: CNDLIterator,  Up: Container
  559.  
  560. CNQueue -- Abstract Queue Base Class
  561. ====================================
  562.  
  563. SYNOPSIS
  564. --------
  565.  
  566.    `#include <CNCL/Queue.h>'
  567.  
  568. TYPE
  569. ----
  570.  
  571.    `CN_QUEUE'
  572.  
  573. * Menu:
  574.  
  575.  
  576. BASE CLASSES
  577. ------------
  578. * CNObject::        Root of the CNCL Hierarchy
  579.  
  580. DERIVED CLASSES
  581. ---------------
  582. * CNQueueFIFO::        FIFO Queue
  583. * CNQueueLIFO::        LIFO Queue
  584. * CNQueueRandom::    Random Queue
  585. * CNQueueSPT::        SPT Queuecontainer
  586. * CNPrioQueueFIFO::    Priority Queue
  587. * CNSink::        Sink
  588.  
  589. RELATED CLASSES
  590. ---------------
  591. * CNJob::        Standard Job for Queues
  592. * CNStack::        Stack
  593.  
  594. DESCRIPTION
  595. -----------
  596.  
  597.    `CNQueue' is a queue of any CNCL compatible object.
  598.  
  599.    Constructors:
  600. `CNQueue();'
  601. `CNQueue(CNParam *param);'
  602.      Initialize the queue.
  603.  
  604.    In addition to the member functions required by CNCL, `CNQueue'
  605. provides the following abstract member function, which must be
  606. implemented by the derived classes:
  607.  
  608. `virtual bool empty() const = 0;'
  609.      Returns `TRUE', if the queue is empty.
  610.  
  611. `virtual bool full() const = 0;'
  612.      Returns `TRUE', if the queue is full.
  613.  
  614. `virtual int length() const = 0;'
  615.      Returns the actual queue length.
  616.  
  617. `virtual void put(CNObject *obj) = 0;'
  618. `void put(CNObject &obj);'
  619.      Puts an object into the queue.
  620.  
  621. `virtual CNObject *get() = 0;'
  622.      Retrieves an object from the queue.
  623.  
  624. `virtual CNObject *peek() = 0;'
  625.      Retrieves an object from the queue. Unlike `get()', the object is
  626.      not removed from the queue.
  627.  
  628. `virtual void delete_all() = 0;'
  629.      Deletes all objects in the queue.
  630.  
  631. 
  632. File: cncl.info,  Node: CNQueueFIFO,  Next: CNQueueLIFO,  Prev: CNQueue,  Up: Container
  633.  
  634. CNQueueFIFO -- FIFO Queue
  635. =========================
  636.  
  637. SYNOPSIS
  638. --------
  639.  
  640.    `#include<CNCL/QueueFIFO.h>'
  641.  
  642. TYPE
  643. ----
  644.  
  645.    `CN_QUEUEFIFO'
  646.  
  647. * Menu:
  648.  
  649.  
  650. BASE CLASSES
  651. ------------
  652. * CNQueue::        Abstract Queue Base Class
  653.  
  654. DERIVED CLASSES
  655. ---------------
  656.  
  657. RELATED CLASSES
  658. ---------------
  659. * CNDLList::        Doubly Linked List of Objects
  660. * CNQueueLIFO::        LIFO Queue
  661. * CNQueueRandom::    Random Queue
  662. * CNQueueSPT::        SPT Queuecontainer
  663. * CNPrioQueueFIFO::    Priority Queue
  664. * CNSink::        Sink
  665. * CNJob::        Standard Job for Queues
  666. * CNStack::        Stack
  667.  
  668. DESCIPTION
  669. ----------
  670.  
  671.    `CNQueueFIFO' is a queue, implemented as a doubly linked list, that
  672. can contain any number (well, sort of ... ;-) CNCL compatible objects.
  673. The queueing strategy is FIFO (First In, First Out).
  674.  
  675.    Constructors:
  676.  
  677. `CNQueueFIFO();'
  678. `CNQueueFIFO(CNParam *param);'
  679.      Initialize the FIFO-queue to an empty state.
  680.  
  681.    In addition to the member functions required by CNCL, `CNQueueFIFO'
  682. provides:
  683.  
  684. `virtual bool empty() const;'
  685.      Returns `TRUE', if the queue is empty.
  686.  
  687. `virtual bool full() const;'
  688.      Always returns `TRUE'.
  689.  
  690. `virtual int length() const;'
  691.      Returns the actual queue length.
  692.  
  693. `virtual void put(CNObject *obj);'
  694.      Puts an object into the queue.
  695.  
  696. `virtual CNObject *get();'
  697.      Retrieves an object from the queue.
  698.  
  699. `virtual CNObject *peek();'
  700.      Retrieves an object from the queue. Unlike `get()', the object is
  701.      not removed from the queue.
  702.  
  703. `virtual void delete_all();'
  704.      Deletes all objects in the queue.
  705.  
  706. 
  707. File: cncl.info,  Node: CNQueueLIFO,  Next: CNQueueRandom,  Prev: CNQueueFIFO,  Up: Container
  708.  
  709. CNQueueLIFO -- LIFO queue
  710. =========================
  711.  
  712. SYNOPSIS
  713. --------
  714.  
  715.    `#include <CNCL/QueueLIFO.h>'
  716.  
  717. TYPE
  718. ----
  719.  
  720.    `CN_QUEUELIFO'
  721.  
  722. * Menu:
  723.  
  724. BASE CLASSES
  725. ------------
  726. * CNQueue::        Abstract queue base class
  727.  
  728. DERIVED CLASSES
  729. ---------------
  730.  
  731. RELATED CLASSES
  732. ---------------
  733. * CNDLList::        Doubly Linked List of Objects
  734. * CNQueueFIFO::        FIFO Queue
  735. * CNQueueRandom::    Random Queue
  736. * CNQueueSPT::        SPT Queuecontainer
  737. * CNPrioQueueFIFO::    Priority Queue
  738. * CNSink::        Sink
  739. * CNJob::        Standard Job for Queues
  740. * CNStack::        Stack
  741.  
  742. DESCRIPTION
  743. -----------
  744.  
  745.    `CNQueueLIFO' is a queue, implemented as a doubly linked list, that
  746. can contain any number (well, sort of ... ;-) CNCL compatible objects.
  747. The queueing strategy is LIFO (Last In, First Out).
  748.  
  749.    Constructors:
  750.  
  751. `CNQueueLIFO();'
  752. `CNQueueLIFO(CNParam *param);'
  753.      Initialize the LIFO-queue to an empty state.
  754.  
  755.    In addition to the member functions required by CNCL, `CNQueueLIFO'
  756. provides:
  757.  
  758. `virtual bool empty() const;'
  759.      Returns `TRUE', if the queue is empty.
  760.  
  761. `virtual bool full() const;'
  762.      Always returns `FALSE'.
  763.  
  764. `virtual int length() const;'
  765.      Returns the actual queue length.
  766.  
  767. `virtual void put(CNObject *obj);'
  768.      Puts an object into the queue.
  769.  
  770. `virtual CNObject *get();'
  771.      Retrieves an object from the queue.
  772.  
  773. `virtual CNObject *peek();'
  774.      Retrieves an object from the queue. Unlike `get()', the object is
  775.      not removed from the queue.
  776.  
  777. `virtual void delete_all();'
  778.      Deletes all objects in the queue.
  779.  
  780. 
  781. File: cncl.info,  Node: CNQueueRandom,  Next: CNQueueSPT,  Prev: CNQueueLIFO,  Up: Container
  782.  
  783. CNQueueRandom -- Random queue
  784. =============================
  785.  
  786. SYNOPSIS
  787. --------
  788.  
  789.    `#include <CNCL/QueueRandom.h>'
  790.  
  791. TYPE
  792. ----
  793.  
  794.    `CN_QUEUERANDOM'
  795.  
  796. * Menu:
  797.  
  798. BASE CLASSES
  799. ------------
  800. * CNQueue::        Abstract queue base class
  801.  
  802. DERIVED CLASSES
  803. ---------------
  804.  
  805. RELATED CLASSES
  806. ---------------
  807. * CNDLList::        Doubly Linked List of Objects
  808. * CNQueueFIFO::        FIFO queue
  809. * CNQueueLIFO::        LIFO queue
  810. * CNQueueSPT::        SPT Queuecontainer
  811. * CNPrioQueueFIFO::    Priority Queue
  812. * CNSink::        Sink
  813. * CNJob::        Standard Job for Queues
  814. * CNStack::        Stack
  815.  
  816. DESCRIPTION
  817. -----------
  818.  
  819.    `CNQueueRandom' is a queue, implemented as a doubly linked list, that
  820. can contain any number (well, sort of ... ;-) CNCL compatible objects.
  821. The queueing strategy is Random, that means there is no ordering in the
  822. queue.
  823.  
  824.    Constructors:
  825.  
  826. `CNQueueRandom();'
  827. `CNQueueRandom(CNParam *param);'
  828. `CNQueueRandom(CNRNG *rng);'
  829.      Initialize the Random-queue to an empty state. One may provide a
  830.      base random number generator (recommended!), otherwise the queue
  831.      provides its own (default setting: `CNFiboG'.)
  832.  
  833.    In addition to the member functions required by CNCL, `CNQueueRandom'
  834. provides:
  835.  
  836. `virtual bool empty() const;'
  837.      Returns `TRUE', if the queue is empty.
  838.  
  839. `virtual bool full() const;'
  840.      Always returns `FALSE'.
  841.  
  842. `virtual int length() const;'
  843.      Returns the actual queue length.
  844.  
  845. `virtual void put(CNObject *obj);'
  846.      Puts an object into the queue.
  847.  
  848. `virtual CNObject *get();'
  849.      Retrieves a random object from the queue.
  850.  
  851. `virtual CNObject *peek();'
  852.      Retrieves an object from the queue. Unlike `get()', the object is
  853.      not removed from the queue.
  854.  
  855. `virtual void delete_all();'
  856.      Deletes all objects in the queue.
  857.  
  858. 
  859. File: cncl.info,  Node: CNQueueSPT,  Next: CNPrioQueueFIFO,  Prev: CNQueueRandom,  Up: Container
  860.  
  861. CNQueueSPT -- SPT queue
  862. =======================
  863.  
  864. SYNOPSIS
  865. --------
  866.  
  867.    `#include <CNCL/QueueSPT.h>'
  868.  
  869. TYPE
  870. ----
  871.  
  872.    `CN_QUEUESPT'
  873.  
  874. * Menu:
  875.  
  876. BASE CLASSES
  877. ------------
  878. * CNQueue::        Abstract queue base class
  879.  
  880. DERIVED CLASSES
  881. ---------------
  882.  
  883. RELATED CLASSES
  884. ---------------
  885. * CNDLList::        Doubly Linked List of Objects
  886. * CNQueueFIFO::        FIFO queue
  887. * CNQueueLIFO::        LIFO Queue
  888. * CNQueueRandom::    Random Queue
  889. * CNPrioQueueFIFO::    Priority Queue
  890. * CNSink::        Sink
  891. * CNJob::        Standard Job for Queues
  892. * CNStack::        Stack
  893.  
  894. DESCRIPTION
  895. -----------
  896.  
  897.    `CNQueueSPT' is a queue, implemented as a doubly linked list, that
  898. can contain any number (well, sort of ... ;-) CNCL compatible
  899. (restrictions see below) objects.  The queueing strategy is SPT, that
  900. means jobs with the shortest processing time are delivered first. The
  901. processing time is read from the public identifier `length' of the
  902. `CNJob' object. SPT queues only accept objects derived from `CNJob'.
  903.  
  904.    Constructors:
  905.  
  906. `CNQueueSPT();'
  907. `CNQueueSPT(CNParam *param);'
  908.      Initialize the SPT-queue to an empty state.
  909.  
  910.    In addition to the member functions required by CNCL, `CNQueueSPT'
  911. provides:
  912.  
  913. `virtual bool empty() const;'
  914.      Returns `TRUE', if the queue is empty.
  915.  
  916. `virtual bool full() const;'
  917.      Always returns `FALSE'.
  918.  
  919. `virtual int length() const;'
  920.      Returns the actual queue length.
  921.  
  922. `virtual void put(CNObject *obj);'
  923.      Puts an object into the queue. Only objects derived from `CNJob'
  924.      may be put into a SPT queue.
  925.  
  926. `virtual CNObject *get();'
  927.      Retrieves the object with the shortest processing time from the
  928.      queue.
  929.  
  930. `virtual CNObject *peek();'
  931.      Retrieves the object with the shortest processing time from the
  932.      queue. Unlike `get()', the object is not removed from the queue.
  933.  
  934. `virtual void delete_all();'
  935.      Deletes all objects in the queue.
  936.  
  937. 
  938. File: cncl.info,  Node: CNPrioQueueFIFO,  Next: CNJob,  Prev: CNQueueSPT,  Up: Container
  939.  
  940. CNPrioQueueFIFO -- Queue with priority
  941. ======================================
  942.  
  943. SYNOPSIS
  944. --------
  945.  
  946.    `#include <CNCL/PrioQueueFIFO.h>'
  947.  
  948. TYPE
  949. ----
  950.  
  951.    `CN_PRIOQUEUEFIFO'
  952.  
  953. * Menu:
  954.  
  955. BASE CLASSES
  956. ------------
  957. * CNQueue::        Abstract queue base class
  958.  
  959. DERIVED CLASSES
  960. ---------------
  961.  
  962. RELATED CLASSES
  963. ---------------
  964. * CNDLList::        Doubly Linked List of Objects
  965. * CNQueueFIFO::        FIFO queue
  966. * CNQueueLIFO::        LIFO Queue
  967. * CNQueueRandom::    Random Queue
  968. * CNQueueSPT::        SPT Queuecontainer
  969. * CNSink::        Sink
  970. * CNJob::        Standard Job for Queues
  971. * CNStack::        Stack
  972.  
  973. DESCRIPTION
  974. -----------
  975.  
  976.    `CNPrioQueueFIFO' is a queue, implemented as some FIFO queues, that
  977. can contain any number (well, sort of ... ;-) CNCL compatible
  978. (restrictions see below) objects.  A priority queue consists of a
  979. number of simple FIFO queues, one for each priority. The priority value
  980. (0 to ...) is taken from the public identifier `priority' of the
  981. `CNJob' object. Lower values mean higher priority in access. Only
  982. objects derived from `CNJob' are accepted.
  983.  
  984.    Constructors:
  985.  
  986. `CNPrioQueueFIFO();'
  987. `CNPrioQueueFIFO(CNParam *param);'
  988. `CNPrioQueueFIFO(int prios);'
  989.      Initialize the priority-queue to an empty state. The `prios' value
  990.      determines the number of different priority steps for. By default
  991.      `prios' is set to two.
  992.  
  993.    In addition to the member functions required by CNCL,
  994. `CNPrioQueueFIFO' provides:
  995.  
  996. `virtual bool empty() const;'
  997.      Returns `TRUE', if all internal queues are empty.
  998.  
  999. `virtual bool full() const;'
  1000.      Always returns `FALSE'.
  1001.  
  1002. `virtual int length() const;'
  1003.      Returns the actual queue length, that means the sum of all
  1004.      internal queues.
  1005.  
  1006. `virtual void put(CNObject *obj);'
  1007.      Puts an object into the queue. Only objects derived from `CNJob'
  1008.      may be put into a priority queue.
  1009.  
  1010. `virtual CNObject *get();'
  1011.      Retrieves an object from the queue. If there are objects in more
  1012.      than one internal queue the object with the lowest value in
  1013.      `priority' is retrieved.
  1014.  
  1015. `virtual CNObject *peek();'
  1016.      Retrieves an object from the queue. Unlike `get()', the object is
  1017.      not removed from the queue.
  1018.  
  1019. `virtual void delete_all();'
  1020.      Deletes all objects in the queue.
  1021.  
  1022. `int priorities();'
  1023.      Returns the number of different prioritie steps.
  1024.  
  1025. 
  1026. File: cncl.info,  Node: CNJob,  Next: CNSink,  Prev: CNPrioQueueFIFO,  Up: Container
  1027.  
  1028. CNJob -- Job object
  1029. ===================
  1030.  
  1031. SYNOPSIS
  1032. --------
  1033.  
  1034.    `#include <CNCL/Job.h>'
  1035.  
  1036. TYPE
  1037. ----
  1038.  
  1039.    `CN_JOB'
  1040.  
  1041. * Menu:
  1042.  
  1043. BASE CLASSES
  1044. ------------
  1045. * CNObject::        Abstract base class
  1046.  
  1047. DERIVED CLASSES
  1048. ---------------
  1049.  
  1050. RELATED CLASSES
  1051. ---------------
  1052. * CNQueueFIFO::        FIFO Queue
  1053. * CNQueueLIFO::        LIFO Queue
  1054. * CNQueueRandom::    Random Queue
  1055. * CNQueueSPT::        SPT Queuecontainer
  1056. * CNPrioQueueFIFO::    Priority Queue
  1057. * CNSink::        Sink
  1058. * CNStack::        Stack
  1059.  
  1060. DESCRIPTION
  1061. -----------
  1062.  
  1063.    `CNJob' is a standard job object for the CNCL queues. FIFO, LIFO and
  1064. Random Queus can contain `CNJob', whereas for SPT and Priority Queues
  1065. must contain it.  Users may derive objects from `CNJob' if they need
  1066. additional data.  `CNJob' provides the following public member
  1067. variables which can be set/read by any user:
  1068. `CNSimTime in;'
  1069. `CNSimTime out;'
  1070. `CNSimTime start;'
  1071. `double orig_length;'
  1072. `double length;'
  1073. `int priority;'
  1074.    The three time variables are used to hold the time when a job enters
  1075. a system, when a job leaves a system and when the serving begins.
  1076. `length' defines the remaining service time of a job while
  1077. `orig_length' defines its whole service time. They are equal in case of
  1078. noninterrupting queueing strategies. `priority' identifies the priority
  1079. of a job used in priority queues.
  1080.  
  1081.    Constructors:
  1082.  
  1083. `CNJob();'
  1084. `CNJob(CNParam *param);'
  1085. `CNJob(double len);'
  1086. `CNJob(int prio);'
  1087. `CNJob(int prio, double len);'
  1088.      Initialize the Job object, optionally setting length and/or
  1089.      priority.
  1090.  
  1091.    `CNJob' provides no additional member functions besides the one
  1092. required by CNCL.
  1093.  
  1094. 
  1095. File: cncl.info,  Node: CNSink,  Next: CNStack,  Prev: CNJob,  Up: Container
  1096.  
  1097. CNSink -- Kitchen Sink
  1098. ======================
  1099.  
  1100. SYNOPSIS
  1101. --------
  1102.  
  1103.    `#include <CNCL/Sink.h.h>'
  1104.  
  1105. TYPE
  1106. ----
  1107.  
  1108.    `CN_SINK'
  1109.  
  1110. * Menu:
  1111.  
  1112. BASE CLASSES
  1113. ------------
  1114. * CNQueue::        Abstract queue base class
  1115.  
  1116. DERIVED CLASSES
  1117. ---------------
  1118.  
  1119. RELATED CLASSES
  1120. ---------------
  1121. * CNDLList::        Doubly Linked List of Objects
  1122. * CNQueueFIFO::        FIFO queue
  1123. * CNQueueLIFO::        LIFO Queue
  1124. * CNQueueRandom::    Random Queue
  1125. * CNQueueSPT::        SPT Queuecontainer
  1126. * CNPrioQueueFIFO::    Priority Queue
  1127. * CNJob::        Standard Job for Queues
  1128. * CNStack::        Stack
  1129.  
  1130. DESCRIPTION
  1131. -----------
  1132.  
  1133.    `CNSink' is a data sink, implemented as queue with only an input
  1134. side. All objects which are put into this sink are destroyed there.
  1135. There is no queueing strategy.
  1136.  
  1137.    Constructors:
  1138.  
  1139. `CNSink();'
  1140. `CNSink(CNParam *param);'
  1141.      Initialize the Sink.
  1142.  
  1143.    In addition to the member functions required by CNCL, `CNSink'
  1144. provides:
  1145.  
  1146. `virtual bool empty() const;'
  1147.      Always returns `TRUE'.
  1148.  
  1149. `virtual bool full() const;'
  1150.      Always returns `FALSE'.
  1151.  
  1152. `virtual int length() const;'
  1153.      Returns the number of objects deleted in the queue.
  1154.  
  1155. `virtual void put(CNObject *obj);'
  1156.      Puts an object into the queue. It will be deleted there.
  1157.  
  1158. `virtual CNObject *get();'
  1159.      Produces an error. A sink is like a black hole.
  1160.  
  1161. `virtual CNObject *peek();'
  1162.      Produces an error. A sink is like a black hole.
  1163.  
  1164. `virtual void delete_all();'
  1165.      Sets the current sink to its initial state, the number of deleted
  1166.      objects is set to zero.
  1167.  
  1168. 
  1169. File: cncl.info,  Node: CNStack,  Next: CNEvent,  Prev: CNSink,  Up: Container
  1170.  
  1171. CNStack -- Stack
  1172. ================
  1173.  
  1174. SYNOPSIS
  1175. --------
  1176.  
  1177.    `#include <CNCL/Stack.h>'
  1178.  
  1179. TYPE
  1180. ----
  1181.  
  1182.    `CN_STACK'
  1183.  
  1184. * Menu:
  1185.  
  1186. BASE CLASSES
  1187. ------------
  1188. * CNQueue::        Abstract queue base class
  1189.  
  1190. DERIVED CLASSES
  1191. ---------------
  1192.  
  1193. RELATED CLASSES
  1194. ---------------
  1195. * CNDLList::        Doubly Linked List of Objects
  1196. * CNQueueFIFO::        FIFO queue
  1197. * CNQueueLIFO::        LIFO Queue
  1198. * CNQueueRandom::    Random Queue
  1199. * CNQueueSPT::        SPT Queuecontainer
  1200. * CNPrioQueueFIFO::    Priority Queue
  1201. * CNSink::        Sink
  1202. * CNJob::        Standard Job for Queues
  1203.  
  1204. DESCRIPTION
  1205. -----------
  1206.  
  1207.    `CNStack' is a stack, implemented as a LIFO queue which can hold any
  1208. number of CNCL compatible objects. It acts very much like a LIFO queue
  1209. but provides another kind of user interface.
  1210.  
  1211.    Constructors:
  1212.  
  1213. `CNStack();'
  1214. `CNStack(CNParam *param);'
  1215. `CNStack(long elem);'
  1216.      Initialize the Stack, optionally setting the size.
  1217.  
  1218.    In addition to the member functions required by CNCL, `CNStack'
  1219. provides:
  1220.  
  1221. `bool empty();'
  1222.      Returns `TRUE' when stack is empty.
  1223.  
  1224. `long depth() const;'
  1225.      Returns the number of objects on the stack.
  1226.  
  1227. `void push(CNObject *obj);'
  1228.      Pushes an object onto the stack.
  1229.  
  1230. `CNObject *pull();'
  1231.      Retrieves the last object from the stack.
  1232.  
  1233. `CNObject *pop();'
  1234.      An alias for `pull()'. Retrieves the last object from the stack.
  1235.  
  1236. `void clear();'
  1237.      Deletes all objects on the stack.
  1238.  
  1239. `long size();'
  1240. `void size(long num);'
  1241.      Gets/sets the maximum depth of the stack.
  1242.  
  1243. 
  1244. File: cncl.info,  Node: Events,  Next: Arrays,  Prev: Container,  Up: Top
  1245.  
  1246. Event Driven Simulation
  1247. ***********************
  1248.  
  1249.    CNCL includes a set of classes for performing event driven
  1250. simulation.
  1251.  
  1252.    For programmers convinience a script `sim.h' has been added to CNCL,
  1253. so that all necessary simulation tools are available by typing
  1254. `#include <sim.h>'. By default the heap scheduler is used, but if the
  1255. special abilities of `CNEventScheduler' are needed, your program only
  1256. needs to define `#define NO_HEAP_SCHEDULER'.
  1257.  
  1258. * Menu:
  1259.  
  1260. CNEvents
  1261. ------
  1262. * CNEvent::        Generic Event
  1263. * CNEventExploder::     Send Events to multiple EventHandlers
  1264. * CNEventHandler::    Abstract Base Class for Event Handlers
  1265. * CNEventList::        List of Events
  1266. * CNEventBaseSched::    Abstract scheduler base class
  1267. * CNEventScheduler::    Event Scheduler
  1268. * CNEventHeapSched::    Event Scheduler using a heap
  1269. * CNEventIterator::     Iterate through event list
  1270. * CNSimTime::        Simulation Time
  1271.  
  1272. * Event Example::    Example of an Event Driven Simulation
  1273.  
  1274. 
  1275. File: cncl.info,  Node: CNEvent,  Next: CNEventExploder,  Prev: CNStack,  Up: Events
  1276.  
  1277. CNEvent -- Generic Event
  1278. ========================
  1279.  
  1280. SYNOPSIS
  1281. --------
  1282.  
  1283.    `#include <CNCL/Event.h>'
  1284.  
  1285. TYPE
  1286. ----
  1287.  
  1288.    `CN_EVENT'
  1289.  
  1290. * Menu:
  1291.  
  1292. BASE CLASSES
  1293. ------------
  1294. * CNDLObject::        Double linked object for CNDLList
  1295.  
  1296. DERIVED CLASSES
  1297. ---------------
  1298.  
  1299. RELATED CLASSES
  1300. ---------------
  1301. * CNEventHandler::    Abstract Base Class for Event Handlers
  1302. * CNEventExploder::     Send Events to multiple EventHandlers
  1303. * CNEventScheduler::    Event Scheduler
  1304. * CNSimTime::        Simulation Time
  1305.  
  1306. DESCRIPTION
  1307. -----------
  1308.  
  1309.    `CNEvent' is a data type for events used in the simulation. Control
  1310. is passed between different event handlers by sending events to each
  1311. other. Events have a unique ID field, a priority, a user defined type,
  1312. an issued and scheduled simulation time, an addressed event handler, a
  1313. sending event handler, and a pointer to an arbitrary CNCL object.
  1314.  
  1315.    `CNEvent's can only be allocated on the heap via `new'.
  1316.  
  1317.    Constructors:
  1318.  
  1319. `CNEvent();'
  1320. `CNEvent(CNParam *param);'
  1321. `CNEvent(int new_type);'
  1322. `CNEvent(int new_type, const CNSimTime t, int prio=0);'
  1323. `CNEvent(int new_type, CNEventHandler *new_to, const CNSimTime t, CNObject *new_object=NIL,'
  1324. `int new_prio=0);'
  1325. `CNEvent(int new_type, CNEventHandler *new_from, CNEventHandler *new_to, const CNSimTime t,'
  1326. `CNObject *new_object=NIL, int new_prio=0);'
  1327. `CNEvent(int new_type, CNEventHandler *new_to, CNObject *new_object=NIL, int new_prio=0);'
  1328.      Initializes the event, optionally setting the event type, the
  1329.      addressed and sending event handler, the scheduled time, the
  1330.      referenced object, and the priority.
  1331.  
  1332.    Destructors:
  1333.  
  1334. `~CNEvent();'
  1335.      Deletes the event. The destructor is private and may only be
  1336.      called from `CNEvent' itself or the friend class
  1337.      `CNEventScheduler'. The destructor does NOT delete the referenced
  1338.      object.
  1339.  
  1340.    In addition to the member functions required by CNCL, `CNEvent'
  1341. provides:
  1342.  
  1343. `static void set_max_events(unsigned long n);'
  1344. `static unsigned long get_max_events();'
  1345.      Gets/Sets maximum number of events. The default value for
  1346.      `max-event' is 100. If `set_max_events()' changes this value, it
  1347.      MUST be called before ANY event is created.
  1348.  
  1349.      If more than `max-event' events are allocated, a `warning' message
  1350.      is printed and the simulation continues with `max-event'
  1351.      multiplied by 10.
  1352.  
  1353. `int priority() const;'
  1354. `void priority(int prio);'
  1355. `int get_priority() const;'
  1356. `void set_priority(int prio);'
  1357.      Gets/sets the event's priority.
  1358.  
  1359. `int type() const;'
  1360. `void type(int new_type);'
  1361. `int get_type() const;'
  1362. `void set_type(int new_type);'
  1363.      Gets/sets the event's type.
  1364.  
  1365. `CNSimTime scheduled() const;'
  1366. `void scheduled(const CNSimTime new_scheduled);'
  1367. `CNSimTime get_scheduled() const;'
  1368. `void set_scheduled(const CNSimTime new_scheduled);'
  1369.      Gets/sets the event's scheduled simulation time.
  1370.  
  1371. `CNSimTime issued() const;'
  1372. `CNSimTime get_issued() const;'
  1373.      Gets the event's issued simulation time.
  1374.  
  1375. `CNEventHandler *to() const;'
  1376. `void to(CNEventHandler *new_to);'
  1377. `CNEventHandler *get_to() const;'
  1378. `void set_to(CNEventHandler *new_to);'
  1379.      Gets/sets the event's addressed event handler.
  1380.  
  1381. `CNEventHandler *from() const;'
  1382. `void from(CNEventHandler *new_from);'
  1383. `CNEventHandler *get_from() const;'
  1384. `void set_from(CNEventHandler *new_from);'
  1385.      Gets/sets the event's sending event handler.
  1386.  
  1387. `CNObject *object() const;'
  1388. `void object(CNObject *obj);'
  1389. `CNObject *get_object() const;'
  1390. `void set_object(CNObject *obj);'
  1391.      Gets/sets the event's referenced object.
  1392.  
  1393. `typedef unsigned long CNEventID;'
  1394. `CNEventID id() const;'
  1395. `CNEventID get_id() const;'
  1396.      Returns the event's unique ID number.
  1397.  
  1398. `static void *operator new(size_t s);'
  1399.      The `new' operator. It is allocating an event out of a pool
  1400.  
  1401. `static void operator delete(void *p);'
  1402.      The `delete' operator.
  1403.  
  1404. `bool after(CNEvent* e2);'
  1405.      Returns `TRUE' if `*this' Event is scheduled after Event `e2'. If
  1406.      both Events are scheduled at the same time, the priority is
  1407.      checked; after that the Event ID. This method is used by the class
  1408.      `CNEventHeapSched'.
  1409.  
  1410. 
  1411. File: cncl.info,  Node: CNEventExploder,  Next: CNEventHandler,  Prev: CNEvent,  Up: Events
  1412.  
  1413. CNEventExploder -- Send Events to multiple EventHandlers
  1414. ========================================================
  1415.  
  1416. SYNOPSIS
  1417. --------
  1418.  
  1419.    `#include <CNCL/EventExploder.h>'
  1420.  
  1421. TYPE
  1422. ----
  1423.  
  1424.    `CN_EVENTEXPLODER'
  1425.  
  1426. * Menu:
  1427.  
  1428. BASE CLASSES
  1429. ------------
  1430. * CNEventHandler::    Abstract Base Class for Event Handlers
  1431.  
  1432. DERIVED CLASSES
  1433. ---------------
  1434.  
  1435. RELATED CLASSES
  1436. ---------------
  1437. * CNEvent::        Generic Event
  1438. * CNEventScheduler::    CNEvent Scheduler
  1439. * CNSimTime::        Simulation Time
  1440.  
  1441. DESCRIPTION
  1442. -----------
  1443.  
  1444.    `CNEventExploder' is a subclass derived from `CNEventHandler'.
  1445. It maintains a list of other arbitrary `CNEventHandler's and forwards
  1446. all received events to all the `CNEventHandler's in its list. This can
  1447. be used to implement "broadcast"-events.
  1448.  
  1449.    Constructors:
  1450.  
  1451. `CNEventExploder();'
  1452. `CNEventExploder(CNParam *param);'
  1453.      Initializes the event exploder.
  1454.  
  1455.    In addition to the member functions required by CNCL,
  1456. `CNEventExploder' provides the following member functions:
  1457.  
  1458. `virtual void event_handler(const CNEvent *ev);'
  1459.      This function receives an event and re-sends it to other
  1460.      `CNEventHandler's.
  1461.  
  1462. `virtual void add_handler(CNEventHandler *eh);'
  1463.      This function adds a new `CNEventHandler' to the list. It will then
  1464.      receive all events that are send to the `CNEventExploder'.
  1465.  
  1466.      If a `CNEventHandler' is added more than once, it will also receive
  1467.      all events as many times.
  1468.  
  1469. `virtual void rem_handler(CNEventHandler *eh);'
  1470.      This function removes a previously added `CNEventHandler' from the
  1471.      list. It will no longer receive events managed by the
  1472.      `CNEventExploder'.
  1473.  
  1474.      If a `CNEventHandler' has been added more than once, it also has to
  1475.      be removed as many times to be completely removed from the
  1476.      `CNEventExploder'.
  1477.  
  1478. 
  1479. File: cncl.info,  Node: CNEventHandler,  Next: CNEventList,  Prev: CNEventExploder,  Up: Events
  1480.  
  1481. CNEventHandler -- Abstract Base Class for Event Handlers
  1482. ========================================================
  1483.  
  1484. SYNOPSIS
  1485. --------
  1486.  
  1487.    `#include <CNCL/EventHandler.h>'
  1488.  
  1489. TYPE
  1490. ----
  1491.  
  1492.    `CN_EVENTHANDLER'
  1493.  
  1494. * Menu:
  1495.  
  1496. BASE CLASSES
  1497. ------------
  1498. * CNNamed::             CNObject with Name
  1499.  
  1500. DERIVED CLASSES
  1501. ---------------
  1502.  
  1503. RELATED CLASSES
  1504. ---------------
  1505. * CNEvent::        Generic Event
  1506. * CNEventScheduler::    CNEvent Scheduler
  1507. * CNSimTime::        Simulation Time
  1508.  
  1509. DESCRIPTION
  1510. -----------
  1511.  
  1512.    `CNEventHandler' is a base class for creating simulation event
  1513. handler. Deriving an event handler class from `CNEventHandler' is
  1514. necessary for the simulation programm.
  1515.  
  1516.    Each derived event handler must at least provide the function
  1517. `event_handler()', which is defined as pure virtual in class
  1518. `CNEventHandler'.
  1519.  
  1520.    Constructors:
  1521.  
  1522. `CNEventHandler();'
  1523. `CNEventHandler(CNParam *param);'
  1524.      Initializes the event handler.
  1525.  
  1526. `CNEventHandler(CNStringR name);'
  1527.      Initializes the event handler, setting the name to `name'.
  1528.  
  1529.    In addition to the member functions required by CNCL,
  1530. `CNEventHandler' provides the following protected member functions
  1531. available to all derived classes:
  1532.  
  1533. `virtual void event_handler(const CNEvent *ev) = 0;'
  1534.      This function must be defined in the derived classes. It should
  1535.      determine what should happen to the transfered Events.  Please see
  1536.      the example at the end of this chapter.
  1537.  
  1538. `CNEventScheduler *scheduler() const;'
  1539.      Returns the scheduler, which called this event handler.
  1540.  
  1541. `int state() const;'
  1542. `int state(int new_state);'
  1543. `int get_state() const;'
  1544. `int set_state(int new_state);'
  1545.      Gets/sets the event handler's state.
  1546.  
  1547. `CNSimTime now() const;'
  1548.      Returns the current simulation time.
  1549.  
  1550. `CNEventID send_event(CNEvent *ev);'
  1551. `CNEventID send(CNEvent *ev);'
  1552.      Send an event to the scheduler. Members left uninitialized in the
  1553.      event are set to default values (scheduled time = current time,
  1554.      addressed event handler = this event handler, sending event
  1555.      handler = this event handler). Returns the event's ID.
  1556.  
  1557. `CNEventID send_now(CNEvent *ev);'
  1558.      Send an event to the scheduler. Same as `send_event()', but
  1559.      scheduled time is set to the current time. Returns the event's ID.
  1560.  
  1561. `CNEventID send_delay(CNEvent *ev, double dt);'
  1562.      Send an event to the scheduler. Same as `send_event()', but
  1563.      scheduled time is set to the current time plus a time delay dt.
  1564.      Returns the event's ID.
  1565.  
  1566. `void delete_event(CNEventID id);'
  1567.      Deletes event with ID `id' from the scheduler's event list.
  1568.  
  1569. `void delete_events(CNEventHandler *evh);'
  1570.      Deletes all events from the list that are addressed to event
  1571.      handler `evh'. If `evh' is `NIL', it deletes all events addressed
  1572.      to this event handler.
  1573.  
  1574. 
  1575. File: cncl.info,  Node: CNEventList,  Next: CNEventBaseSched,  Prev: CNEventHandler,  Up: Events
  1576.  
  1577. CNEventList -- List of Events
  1578. =============================
  1579.  
  1580. SYNOPSIS
  1581. --------
  1582.  
  1583.    `#include <CNCL/EventList.h>'
  1584.  
  1585. TYPE
  1586. ----
  1587.  
  1588.    `CN_EVENTLIST'
  1589.  
  1590. * Menu:
  1591.  
  1592. BASE CLASSES
  1593. ------------
  1594. * CNObject::        Root of the CNCL Hierarchy
  1595.  
  1596. DERIVED CLASSES
  1597. ---------------
  1598.  
  1599. RELATED CLASSES
  1600. ---------------
  1601. * CNEvent::        Generic Event
  1602. * CNEventScheduler::    CNEvent Scheduler
  1603.  
  1604. DESCRIPTION
  1605. -----------
  1606.  
  1607.    `CNEventList' is the list of events managed by `CNEventScheduler'.
  1608. It is a wrapper around `CNDLList' for creating a list of sorted events.
  1609. CNEvents are sorted by their scheduled time and their priority.
  1610.  
  1611.    Constructors:
  1612.  
  1613. `CNEventList();'
  1614. `CNEventList(CNParam *param);'
  1615.      Initializes the event list to empty.
  1616.  
  1617.    In addition to the member functions required by CNCL, `CNEventList'
  1618. provides:
  1619.  
  1620. `void add_event(CNEvent *ev);'
  1621.      Adds an event to the list.
  1622.  
  1623. `void delete_event(CNEventID id);'
  1624.      Deletes an event from the list, using the ID code.
  1625.  
  1626. `void delete_events(CNEventHandler *evh, bool to);'
  1627.      Deletes all events from the list. If `to' equals TRUE the events
  1628.      addressed to event handler `evh' are deleted, else the events
  1629.      coming from that event handler.
  1630.  
  1631. `void delete_all(CNEventID id);'
  1632.      Deletes all events from the list.
  1633.  
  1634. `CNEvent *next_event();'
  1635.      Gets the next event (the one at the front) from the list.
  1636.  
  1637. `CNEvent *peek_event();'
  1638. `CNEvent *peek_event(CNEventID id);'
  1639.      Returns a pointer to the next scheduled event or a pointer to the
  1640.      event with ID `id', `NIL' if not available.
  1641.  
  1642. 
  1643. File: cncl.info,  Node: CNEventBaseSched,  Next: CNEventScheduler,  Prev: CNEventList,  Up: Events
  1644.  
  1645. CNEventBaseSched -- Abstract scheduler base class
  1646. =================================================
  1647.  
  1648. SYNOPSIS
  1649. --------
  1650.  
  1651.    `#include <CNCL/EventBaseSched.h>'
  1652.  
  1653. TYPE
  1654. ----
  1655.  
  1656.    `CN_EVENTBASESCHED'
  1657.  
  1658. * Menu:
  1659.  
  1660. BASE CLASSES
  1661. ------------
  1662.  
  1663. * CNObject::        Root of the CNCL Hierarchy
  1664.  
  1665. DERIVED CLASSES
  1666. ---------------
  1667.  
  1668. RELATED CLASSES
  1669. ---------------
  1670.  
  1671. DESCRIPTION
  1672. -----------
  1673.  
  1674.    Constructors:
  1675.  
  1676. `CNEventBaseSched();'
  1677. `CNEventBaseSched(CNParam *);'
  1678.      Initializes the `CNEventBaseSched'.
  1679.  
  1680.    In addition to the member functions required by CNCL,
  1681. `CNEventBaseSched' provides:
  1682.  
  1683. `CNSimTime::time();'
  1684.      Returns the simulation time.
  1685.  
  1686. `CNStatistics *statistics() const;'
  1687. `void statistics(CNStatistics *st);'
  1688.      Sets/Gets the (optional) scheduler statistic. By default no
  1689.      statistic is used.
  1690.  
  1691. `void delete_events_from(CNEventHandler *h);'
  1692. `void delete_events_to(CNEventHandler *h);'
  1693.      Deletes the events coming `from' or adressed `to' the eventhandler
  1694.      `h'.
  1695.  
  1696.      The following functions are defined virtual and must be defined in
  1697.      derived classes:
  1698.  
  1699. `void add_event(CNEvent *ev)=0;'
  1700. `void send_event(CNEvent *ev)=0;'
  1701.      Adds/sends an event to an event handler.
  1702.  
  1703. `void delete_event(CNEventID id)=0;'
  1704.      Deletes event with ID `id'.
  1705.  
  1706. `void delete_events(CNEventHandler *evh, bool to=TRUE)=0;'
  1707.      Deletes all events from the list that are addressed to or are
  1708.      comming from event handler `evh'.
  1709.  
  1710. `CNEvent *peek_event()=0;'
  1711. `CNEvent *peek_event(CNEventID id)=0;'
  1712.      Peeks at next event or event with ID `id'. Returns pointer to
  1713.      event, or `NIL' if not available.
  1714.  
  1715. `CNEvent *next_event() = 0;'
  1716.      Retrieves next event from internal data structure.
  1717.  
  1718. `void start();'
  1719. `void start(CNEvent *ev);'
  1720.      Starts the scheduler with an optional initialization event.
  1721.  
  1722. `void stop()=0;'
  1723.      Stops the scheduler after processing the current event and deletes
  1724.      all pending events in the event list. May be used inside an event
  1725.      handler to stop the simulation.
  1726.  
  1727. `CNEventIterator *create_iterator() = 0;'
  1728.      Creates an event iterator.
  1729.  
  1730. `void process_events();'
  1731.      Process all events.
  1732.  
  1733. `void process_now();'
  1734.      Processes  all events scheduled for the actual simtime..
  1735.  
  1736. 
  1737. File: cncl.info,  Node: CNEventScheduler,  Next: CNEventHeapSched,  Prev: CNEventBaseSched,  Up: Events
  1738.  
  1739. CNEventScheduler -- Event Scheduler
  1740. ===================================
  1741.  
  1742. SYNOPSIS
  1743. --------
  1744.  
  1745.    `#include <CNCL/EventScheduler.h>'
  1746.  
  1747. TYPE
  1748. ----
  1749.  
  1750.    `CN_EVENTSCHEDULER'
  1751.  
  1752. * Menu:
  1753.  
  1754. BASE CLASSES
  1755. ------------
  1756.  
  1757. * CNEventBaseSched::    Abstract scheduler base class
  1758.  
  1759. DERIVED CLASSES
  1760. ---------------
  1761.  
  1762. RELATED CLASSES
  1763. ---------------
  1764. * CNEvent::        Generic Event
  1765. * CNEventHandler::    Abstract Base Class for Event Handlers
  1766. * CNEventList::        List of Events
  1767. * CNEventHeapSched::Faster Event Scheduler using a heap
  1768.  
  1769. DESCRIPTION
  1770. -----------
  1771.  
  1772.    `CNEventScheduler' is the central simulation control. It manages the
  1773. events and delivers them to the addressed event handlers.
  1774.  
  1775.    Scheduled events are sorted with respect to their scheduled
  1776. simulation time and their priority. If there are two or more events
  1777. with exactly the same scheduled simulation time and the same priority,
  1778. they are processed in FIFO order.
  1779.  
  1780.    If this exact behaviour is not strictly required, if scheduled
  1781. simulation time and priority are sufficient to determine the procession
  1782. order of events, then CNEventHeapSched should be used instead of
  1783. CNEventScheduler. CNEventHeapSched avoids some potential performace
  1784. deficiencies CNEventScheduler might show.
  1785.  
  1786.    Constructors:
  1787.  
  1788. `CNEventScheduler();'
  1789. `CNEventScheduler(CNParam *param);'
  1790.      Initializes the event scheduler.
  1791.  
  1792.    In addition to the member functions required by CNCL,
  1793. `CNEventScheduler' provides:
  1794.  
  1795. `void add_event(CNEvent *ev);'
  1796. `void send_event(CNEvent *ev);'
  1797.      Adds/sends an event to an event handler.
  1798.  
  1799. `void delete_event(CNEventID id);'
  1800.      Deletes event with ID `id'.
  1801.  
  1802. `void delete_events(CNEventHandler *evh, bool to=TRUE);'
  1803.      Deletes all events from the list that are addressed to event
  1804.      handler `evh' or that are coming from the event handler if `to'
  1805.      equals FALSE.
  1806.  
  1807. `CNEvent *peek_event();'
  1808. `CNEvent *peek_event(CNEventID id);'
  1809. `CNEvent *next_event();'
  1810.      Peeks next event or event with ID `id'. Returns pointer to event,
  1811.      or `NIL' if not available.
  1812.  
  1813. `void stop();'
  1814.      Stops the scheduler after processing the current event and deletes
  1815.      all pending events in the event list. May be used inside an event
  1816.      handler to stop the simulation.
  1817.  
  1818. `CNEventIterator *create_iterator();'
  1819.      Creates an iterator object to traverse the list of events.
  1820.  
  1821. 
  1822. File: cncl.info,  Node: CNEventHeapSched,  Next: CNEventIterator,  Prev: CNEventScheduler,  Up: Events
  1823.  
  1824. CNEventHeapSched -- Event Scheduler using a heap
  1825. ================================================
  1826.  
  1827. SYNOPSIS
  1828. --------
  1829.  
  1830.    `#include <CNCL/EventHeapSched.h>'
  1831.  
  1832. TYPE
  1833. ----
  1834.  
  1835.    `CN_EVENTHEAPSCHED'
  1836.  
  1837. * Menu:
  1838.  
  1839. BASE CLASSES
  1840. ------------
  1841. * CNEventBaseSched::    Abstract scheduler base class
  1842.  
  1843.  
  1844. DERIVED CLASSES
  1845. ---------------
  1846.  
  1847. RELATED CLASSES
  1848. ---------------
  1849. * CNEvent::        Generic Event
  1850. * CNEventHandler::    Abstract Base Class for Event Handlers
  1851. * CNEventScheduler::    Standard Event Scheduler
  1852.  
  1853. DESCRIPTION
  1854. -----------
  1855.  
  1856.    `CNEventHeapSched' is a replacement for `CNEventScheduler'. From the
  1857. user's point of view, it is completely compatible, but it differs in
  1858. the internally used datastructures and algorithms.
  1859.  
  1860.    If a high number of events is used simultaneously, the eventlist
  1861. used in `CNEventScheduler' can become very slow. `CNEventHeapSched'
  1862. solves that problem by using a more efficient algorithm, a "heap".
  1863.  
  1864.    However there is one drawback with `CNEventHeapSched': in contrast
  1865. to `CNEventScheduler' no FIFO order of processing can be guaranteed if
  1866. events compare equal. If there are for example two or more events with
  1867. exactly the same scheduled simulation time and the same priority, then
  1868. they are processed in random order.
  1869.  
  1870.    Constructors:
  1871.  
  1872. `CNEventHeapSched();'
  1873. `CNEventHeapSched(CNParam *param);'
  1874.      Initializes the event scheduler.
  1875.  
  1876.    In addition to the member functions required by CNCL,
  1877. `CNEventHeapSched' provides:
  1878.  
  1879. `void add_event(CNEvent *ev);'
  1880. `void send_event(CNEvent *ev);'
  1881.      Adds/sends an event to an event handler.
  1882.  
  1883. `void delete_event(CNEventID id);'
  1884.      Deletes event with ID `id'.
  1885.  
  1886. `void delete_events(CNEventHandler *evh, bool to=TRUE);'
  1887.      Deletes all events from the list that are addressed to or are
  1888.      comming from event handler `evh'.
  1889.  
  1890. `CNEvent *peek_event();'
  1891. `CNEvent *peek_event(CNEventID id);'
  1892.      Peeks at next event or event with ID `id'. Returns pointer to
  1893.      event, or `NIL' if not available.
  1894.  
  1895. `CNEvent *next_event();'
  1896.      Gets (and removes) the next `CNEvent' from the current heap.
  1897.  
  1898. `void stop();'
  1899.      Stops the scheduler after processing the current event and deletes
  1900.      all pending events in the event list. May be used inside an event
  1901.      handler to stop the simulation.
  1902.  
  1903. `CNEventIterator *create_iterator();'
  1904.      Creates an iterator object to traverse the list of events.
  1905.  
  1906. 
  1907. File: cncl.info,  Node: CNEventIterator,  Next: CNSimTime,  Prev: CNEventHeapSched,  Up: Events
  1908.  
  1909. CNEventIterator -- iterate through event list
  1910. =============================================
  1911.  
  1912. SYNOPSIS
  1913. --------
  1914.  
  1915.    `#include <CNCL/EventLIterator.h>' `#include <CNCL/EventHIterator.h>'
  1916.  
  1917. TYPE
  1918. ----
  1919.  
  1920.    `CN_EVENTLITERATOR' `CN_EVENTHITERATOR'
  1921.  
  1922. * Menu:
  1923.  
  1924. BASE CLASSES
  1925. ------------
  1926. * CNObject::    Root of the CNCL Hierarchy
  1927.  
  1928. DERIVED CLASSES
  1929. ---------------
  1930.  
  1931. ELATED CLASSES
  1932. ---------------
  1933. * CNEvent::             Generic Event
  1934. * CNEventScheduler::    CNEvent Scheduler
  1935. * CNEventHeapSched::    HeapEventScheduler
  1936.  
  1937. DESCRIPTION
  1938. -----------
  1939.  
  1940.    The classes `CNEventLIterator' and `CNEventHIterator' are used to
  1941. step through the list of events. Single events may be deleted. The
  1942. classes can only be created on the heap by calling the member function
  1943. `create_iterator' of the current scheduler.
  1944.  
  1945.    `CNEventLIterator' and `CNEventHIterator' provide in addition to the
  1946. member functions required by CNCL:
  1947.  
  1948. `CNEvent *next_event();'
  1949.      Returns an event every time it is called. In case the
  1950.      `CNEventHeapSched' is used it can not be guaranteed that the same
  1951.      event is delivered only once.  Furthermore the order in which the
  1952.      events are delivered needn't obey any rule. It is however
  1953.      guaranteed that every event will be returned at least once.
  1954.  
  1955. `void delete_current_event()'
  1956.      Deletes the event last returned by `next_event()'.
  1957.  
  1958.